<?php

/**
 * Erra_Fields_Text - Simple text field
 *
 * @package
 * @author Alexis Eric
 * @copyright Copyright (c) 2012 - Erra Prod
 * @version $1.0$
 * @access public
 */
class Erra_Fields_Search_Text extends Erra_Fields_Base_Field {

    protected $_operator = null;
    protected $_size = 40;

    function __construct($objectId) {
        parent::__construct($objectId);
        $this->setDatabaseType('none');
    }

    /**
     * Erra_Fields_Text::editInstance() - Shows a simple text field
     *
     * @param mixed $lang
     * @return
     */
    public function editInstance(Array $extraProperties=null) {
        $res = '<div class="erra-form-field-instance">';
        $res .= $this->outputFieldHeader();
        $size = (!is_null($this->_size)) ? ' size="' . $this->_size . '" ' : '';
        $res .= '<input type="hidden" name="' . $this->getHtmlName() . '[operator]" id="' . $this->getHtmlId() . '_operator" value="' . $this->getOperator() . '"/>';
        $res .= '<input '.$this->getHtmlAttributes($extraProperties).' type="text" name="' . $this->getHtmlName() . '[criteria]" id="' . $this->getHtmlId() . '_criteria" value="' . $this->getRawData() . '"  ' . $size . '/>';
        $res .= '</div>';
        return $res;
    }

    function toHtml($displayParameters=null) {
        return $this->getRawData();
    }
    
    public function setOperator($operator) {
        $this->_operator = $operator;
        return $this;
    }
    
    public function getOperator() {
        return $this->_operator;
    }

}